<template>
    <header class="header flex-between padding-0-30" :class="{'hide': isHide, 'backg': !isTransparent}">
      <div class="name">LiuTingting</div>
      <nav>
        <ul class="flex-center">
          <li>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-tubiao1yihuifu-06"></use>
            </svg>
            <span>首页</span>
          </li>
          <li>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-tubiao1yihuifu-06"></use>
            </svg>
            <span>首页</span>
          </li>
          <li>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-tubiao1yihuifu-06"></use>
            </svg>
            <span>首页</span>
          </li>
          <li>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-tubiao1yihuifu-06"></use>
            </svg>
            <span>首页</span>
          </li>
        </ul>
      </nav>
      <div class="search flex">
        <div> <input type="text" placeholder="Search . . ." required> </div>
      </div>
      
    </header>
  </template>
  <script setup lang="ts">
  import {ref,reactive} from "vue"
  
  const isHide = ref(false)
  const isTransparent = ref(true)

  onMounted(() => {
    window.addEventListener('mousewheel', handleMousewheel )
  })

  onBeforeUnmount(() => {
    window.removeEventListener('mousewheel', handleMousewheel)
  })

  function handleMousewheel(e) {

    if (e.deltaY > 0) {
      // 隐藏
      isHide.value = true
    } else {
      isHide.value = false
      isTransparent.value = window.scrollY < 375
    }
  }
  
  
  
  </script>
  <style lang="scss" scoped>
  .header {
    position: fixed;
    left: 0;
    right: 0;
    height: 60px;
    background-color: transparent;
    transition: all .3s;
    z-index: 1;
    color: var(--cFFF);
    // mix-blend-mode: difference;
    &:not(.backg):hover {
      background-color: rgba(0,0,0,.5);
    }
    .name {
      flex: 1;
      letter-spacing: 2px;
      font-weight: 600;
      font-size: 22px;
    }
    nav {
      font-size: 16px;
      flex: 4;
      ul {
        width: 100%;
        li {
          position: relative;
          padding: 10px 0;
          margin: 0 10px;
          cursor: pointer;
          span {
            margin-left: 5px;
          }
          &::after {
            position: absolute;
            content: '';
            left: 0;
            bottom: 0;
            height: 3px;
            width: 0;
            background-color: orange;
            transition: all .3s;
          }
          &:hover {
            color: orange;
            &::after {
              width: 100%;
            }
          }
        }
      }
    }
    .test {
      flex: 1;
    }
  }
  .hide {
    opacity: 0;
  }
  .backg {
    background-color: rgba($color: #fff, $alpha: 1);
    color: #000 !important;
  }
  
  // search
.search {
  flex: 1;
  justify-content: flex-end;
}
  .search > div {
    display: inline-block;
    position: relative;
    filter: drop-shadow(0 1px #0091c2);
  }
  
  .search > div:after {
    content: "";
    background: white;
    width: 4px;
    height: 10px;
    position: absolute;
    top: 25px;
    right: 0;
    transform: rotate(135deg);
  }
  
  .search > div > input {
    color: white;
    font-size: 16px;
    background: transparent;
    width: 30px;
    height: 30px;
    padding: 10px;
    border: solid 3px white;
    outline: none;
    border-radius: 35px;
    transition: width 0.5s;
  }
  
  .search > div > input::placeholder {
    color: #efefef;
    opacity: 0;
    transition: opacity 150ms ease-out;
  }
  
  .search > div > input:focus::placeholder {
    opacity: 1;
  }
  
  .search > div > input:focus,
  .search > div > input:not(:placeholder-shown) {
    width: 200px;
  }
  
  </style>
  